import { ReqPage, ResPage } from '@/api/interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'

/**山峰模块 */
export namespace ResearchActivities {
  /**查询参数 */
  export interface Query extends ReqPage {
    name?: string
    holdDate?: any
    holdDateBegin?: string
    holdDateEnd?: string
  }

  /**列表内容 */
  export interface Record {
    id: number
    name: string
    categoryId: number
    categoryName: string
    typeId: number
    typeName: string
    holdDate: string
    holdDateFormat: string
    longitude: string
    latitude: string
  }

  /**详情 */
  export interface Form {
    id: number
    name: string
    categoryId: number
    typeId: number
    holdDate: string
    address: string
    content: string
    longitude: string
    latitude: string
  }
}

// 分页查询
export const pageResearchActivities = (params: ResearchActivities.Query) => {
  return http.get<ResPage<ResearchActivities.Record>>(TBY + `/research_activities/page`, params)
}

// 山峰详情
export const getResearchActivitiesDetail = (id: number) => {
  return http.get<Partial<ResearchActivities.Form>>(TBY + `/research_activities/get`, { id }, { loading: false })
}

// 新增或修改山峰
export const saveOrUpdateResearchActivities = (params: Partial<ResearchActivities.Form>) => {
  return http.post(TBY + `/research_activities/save`, params)
}

// 删除山峰
export const removeResearchActivities = (id: number) => {
  return http.delete(TBY + `/research_activities/delete`, { id })
}
